package com.sevennotes.classtable.data.database.daos

import androidx.lifecycle.LiveData
import androidx.room.*
import com.sevennotes.classtable.model.GradePointRecord

@Dao
interface GradePointRecordDAO {
    @Insert
     fun insertGradePointRecord(gradePointRecord: GradePointRecord)

    @Update
     fun updateGradePointRecord(gradePointRecord: GradePointRecord)

    @Delete
     fun deleteGradePointRecord(gradePointRecord: GradePointRecord)

     @Query("DELETE FROM grade_point_record")
     fun clear()

     @Query("SELECT * FROM grade_point_record")
     fun getAllGPRForBack():List<GradePointRecord>

    @Query("SELECT * FROM grade_point_record WHERE student_id = :studentId")
     fun getAllGradePointRecordByStudentId(studentId: Int): LiveData<List<GradePointRecord>>

    @Query("SELECT * FROM grade_point_record WHERE student_id = :studentId")
    fun getAllById(studentId: Int): List<GradePointRecord>

    @Query("DELETE FROM grade_point_record WHERE student_id = :studentId")
     fun deleteAllByStudentId(studentId: Int)
}